package com.atguigu.yygh.hosp.controller.admin;

import com.atguigu.yygh.common.result.R;
import com.atguigu.yygh.hosp.service.ScheduleService;
import com.atguigu.yygh.model.hosp.Schedule;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author mgx
 * @version 1.0
 * @description: 排班的controller
 * @date 2022/8/30 16:11
 */
@RestController
@RequestMapping("/admin/hosp/schedule")
@Api(tags = {"排班信息管理"})
public class ScheduleController {

    @Autowired
    private ScheduleService scheduleService;

    @ApiOperation(value = "根据医院部门编码和日期获取当前排班详情")
    @GetMapping("/{hoscode}/{depcode}/{workDate}")
    public R getDetailSchedule(@PathVariable("hoscode")String hoscode,
                               @PathVariable("depcode")String depcode,
                               @PathVariable("workDate")String workDate) {
        List<Schedule> list = scheduleService.detail(hoscode, depcode, workDate);
        return R.ok().data("list",list);
    }

    @ApiOperation(value = "医院排班信息的分页查询")
    @GetMapping("/{pageNum}/{pageSize}/{hoscode}/{depcode}")
    public R getSchedulePage(@PathVariable("pageNum") Integer pageNum,
                             @PathVariable("pageSize") Integer pageSize,
                             @PathVariable("hoscode")String hoscode,
                             @PathVariable("depcode")String depcode) {
        Map<String, Object> res = scheduleService.page(pageNum, pageSize, hoscode, depcode);
        return R.ok().data(res);
    }
}
